package cn.moondev.game.entity;

public enum State {

    ALIVE{
        @Override
        public State judge(int aliveNeighborNum) {
            return aliveNeighborNum >= 2 && aliveNeighborNum <= 3 ? ALIVE : DEATH;
        }
    },
    DEATH{
        @Override
        public State judge(int aliveNeighborNum) {
            return aliveNeighborNum == 3 ? ALIVE : DEATH;
        }
    };
    
    /**
     * 根据当前状态以及周围的存活的邻居数量判断下一代该细胞的存活状态
     * @param aliveNeighborNum  周围存活的邻居数量
     */
    public abstract State judge(int aliveNeighborNum);
}
